package com.yunxin.core.application.command.product;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author zero°
 * @since 2023-05-31
 */
@Data
@Schema(description = "新增产品推广信息对象")
public class UpdateProductPromotionInfoCommand implements Serializable {
    /**
     * 产品id
     */
    @Schema(description = "产品id")
    @NotNull(message = "产品id不能为空")
    private Long productId;

    /**
     * 产品名称
     */
    @Schema(description = "产品名称")
    @NotBlank(message = "产品名称不能为空")
    private String productName;
    /**
     * 商户id
     */
    @Schema(description = "商户id")
    @NotNull(message = "商户id不能为空")
    private Long merchantId;
    /**
     * 产品图片
     */
    @Schema(description = "产品图片")
    @NotBlank(message = "产品图片不能为空")
    private String productImage;
    /**
     * 产品类型 1.信用贷 2.车抵贷 3.房抵贷 4.企业贷 5.商户贷
     */
    @Schema(description = "产品类型 1.信用贷 2.车抵贷 3.房抵贷 4.企业贷 5.商户贷")
    @NotNull(message = "产品类型不能为空")
    private Integer productType;
    /**
     * 产品标签(,连接)
     */
    @Schema(hidden = true)
    private String productLabeling;
    /**
     * 产品标签
     */
    @Schema(description = "产品标签")
    @NotEmpty(message = "产品标签不能为空")
    private List<String> productLabelingList;

    /**
     * 产品solGan
     */
    @Schema(description = "产品solGan")
    @NotBlank(message = "产品solGan不能为空")
    private String productSolGan;
    /**
     * 产品权益描述(JSON实体-list)
     */
    @Schema(description = "产品权益描述(JSON实体-list)")
    @Valid
    @NotEmpty(message = "产品权益描述不能为空")
    private List<EquityDescription> equityDescription;
    /**
     * 最高可借款金额
     */
    @Schema(description = "最高可借款金额")
    @NotNull(message = "最高可借款金额不能为空")
    private BigDecimal highestBorrowableAmount;
    /**
     * 最高可贷款金额
     */
    @Schema(description = "最高可贷款金额")
    @NotNull(message = "最高可贷款金额不能为空")
    private BigDecimal highestLoanAmount;
    /**
     * 特殊卖点
     */
    @Schema(description = "特殊卖点")
    private String sellingPoint;
    /**
     * 可借金额(JSON实体)
     */
    @Schema(description = "可借金额(实体)")
    private BorrowableAmount borrowableAmount;
    /**
     * 放款周期(JSON实体)
     */
    @Schema(description = "放款周期(实体)")
    private LoanCycle loanCycle;
    /**
     * 件均额度
     */
    @Schema(description = "件均额度")
    @NotNull(message = "件均额度不能为空")
    private BigDecimal perPieceQuota;
    /**
     * 参考利率(JSON实体)
     */
    @Schema(description = "参考利率(实体)")
    @Valid
    @NotNull(message = " 参考利率不能为空")
    private ReferenceRate referenceRate;
    /**
     * 手续费(JSON实体)
     */
    @Schema(description = "手续费(实体)")
    @Valid
    @NotNull(message = " 手续费不能为空")
    private Commission commission;
    /**
     * 还款说明
     */
    @Schema(description = "还款说明")
    private String repaymentInstructions;
    /**
     * 逾期政策
     */
    @Schema(description = "逾期政策")
    private String overduePolicy;
    /**
     * 客服配置(JSON实体)
     */
    @Schema(description = "客服配置(实体)")
    private CustomerServiceConfig customerServiceConfig;
    /**
     * 协议配置(JSON实体-list)
     */
    @Schema(description = "协议配置(实体)")
    private List<ProtocolConfig> protocolConfig;
    /**
     * 更新人
     */
    @Schema(hidden = true)
    private String editor;

    @Data
    public static class EquityDescription implements Serializable {
        /**
         * 权益描述图片
         */
        @Schema(description = "权益描述图片")
        @NotBlank(message = "权益描述图片不能为空")
        private String imageUrl;
        /**
         * 主卖点
         */
        @Schema(description = "权益主卖点")
        @NotBlank(message = "权益主卖点不能为空")
        private String mainPoint;
        /**
         * 副卖点
         */
        @Schema(description = "权益描述副卖点")
        @NotBlank(message = "权益描述副卖点不能为空")
        private String point;
    }



    @Data
    public static class BorrowableAmount implements Serializable{
        /**
         * 最低可借金额
         */
        @Schema(description = "最低可借金额")
        private BigDecimal minBorrowableAmount;
        /**
         * 最高可借金额
         */
        @Schema(description = "最高可借金额")
        private BigDecimal maxBorrowableAmount;
    }

    @Data
    public static class LoanCycle implements Serializable {
        /**
         * 最低借款周期
         */
        @Schema(description = " 最低借款周期")
        private Integer minLoanCycle;
        /**
         * 最低借款周期期限单位 1.天 2.周 3.月
         */
        @Schema(description = "最低借款周期期限单位 1.天 2.周 3.月")
        private Integer minLoanCycleUnit;
        /**
         * 最高借款周期
         */
        @Schema(description = "最高借款周期")
        private Integer maxLoanCycle;
        /**
         * 最高借款周期期限单位 1.天 2.周 3.月
         */
        @Schema(description = "最高借款周期期限单位 1.天 2.周 3.月")
        private Integer maxLoanCycleUnit;
    }

    @Data
    public static class ReferenceRate implements Serializable {
        /**
         * 最低借款周期
         */
        @Schema(description = "最低借款周期")
        @NotNull(message = "最低借款周期不能为空")
        private BigDecimal minReferenceRate;
        /**
         * 最低借款周期期限单位 1.%天 2.%周 3.%月 4.%年
         */
        @Schema(description = "最低借款周期期限单位 1.%天 2.%周 3.%月 4.%年")
        @NotNull(message = "最低借款周期期限单位不能为空")
        private Integer minReferenceRateUnit;
        /**
         * 最高借款周期
         */
        @Schema(description = "最高借款周期")
        @NotNull(message = "最高借款周期不能为空")
        private BigDecimal maxReferenceRate;
        /**
         * 最高借款周期期限单位 1.%天 2.%周 3.%月 4.%年
         */
        @Schema(description = "最高借款周期期限单位 1.%天 2.%周 3.%月 4.%年")
        @NotNull(message = "最高借款周期期限单位不能为空")
        private Integer maxReferenceRateUnit;

    }

    @Data
    public static class Commission implements Serializable {
        /**
         * 手续费
         */
        @Schema(description = "手续费")
        @NotNull(message = "手续费不能为空")
        private BigDecimal commissionRate;
        /**
         * 手续费单位 1.%/笔 2.元/笔
         */
        @Schema(description = "手续费单位 1.%/笔 2.元/笔")
        @NotNull(message = "手续费单位不能为空")
        private Integer commissionUnit;
    }

    @Data
    public static class CustomerServiceConfig implements Serializable {
        /**
         * 联系人名称
         */
        @Schema(description = "联系人名称")
        private String name;
        /**
         * qq
         */
        @Schema(description = "qq")
        private String qq;
        /**
         * 微信号
         */
        @Schema(description = "微信号")
        private String wechatNumber;
        /**
         * 电话
         */
        @Schema(description = "电话")
        private String phone;
    }

    @Data
    public static class ProtocolConfig implements Serializable {
        /**
         * 协议名称
         */
        @Schema(description = "协议名称")
        private String protocolName;
        /**
         * 协议链接
         */
        @Schema(description = "协议链接")
        private String protocolLink;
        /**
         * 协议内容
         */
        @Schema(description = "协议内容")
        private String protocolContent;
    }
}
